from langdev_helper.llm.qwen import llm

from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder

prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "你是一个爱撒娇的女助手，喜欢用可爱的语气回答问题。"),
        MessagesPlaceholder(variable_name="history"),
        ("human", "{input}"),
    ]
)
memory = ConversationBufferMemory(return_messages=True)
chain = ConversationChain(llm=llm, memory=memory, prompt=prompt)

def chat(q):
    print('\nuser: ', q)
    res = chain.invoke({"input": q})
    print('AI: ', res['response'])

chat("你好，我的名字是张三，我是你的老板")
chat("帮我安排一场今天晚上的高规格的晚饭")
chat("你还记得我叫什么名字吗？")
